package com.ruoyi.water.mapper;

import com.ruoyi.water.domain.MeterWarn;
import org.apache.ibatis.annotations.Insert;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface MeterWarnMapper extends CommonMapper<MeterWarn>  {
    /**
     * 批量插入并忽略重复记录（基于表中唯一约束）
     */
    @Insert("<script>" +
            "INSERT IGNORE INTO t_meterwarn (" +
            "meterId, elemName, warnLevel, warnType, warnMsg, warnTime, warnStatus, recordTime" +
            ") VALUES " +
            "<foreach collection='list' item='item' separator=','>" +
            "(#{item.meterId}, #{item.elemName}, #{item.warnLevel}, #{item.warnType}, " +
            "#{item.warnMsg}, #{item.warnTime}, #{item.warnStatus}, #{item.recordTime})" +
            "</foreach>" +
            "</script>")
    int insertBatchIgnoreDuplicates(@Param("list") List<MeterWarn> list);
}